<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <nav-bar></nav-bar>

        <hr>
        <nav-bar></nav-bar>

        <hr>
        <nav-bar></nav-bar>

    </div>

    <!-- 模板内容 -->
    <template id="hello">
        <div>
            <p>{{ name }}</p>
            <h2>{{ age }}</h2>
            <button @click="modify">修改age</button>
        </div>
    </template>
    
    <script>
        // 创建一个Vue实例,其本质上也是一个组件,称为根组件
        new Vue({
            data: {
                msg: 'hello'
            },
            components: { // 定义组件
                NavBar: {
                    template: '#hello',
                    data(){
                        return {
                            name: 'tom',
                            age: 18
                        }
                    },
                    methods: {
                        modify(){
                            this.age = 20
                        }
                    }
                },
                'comp-a': {
                    
                }
            }
        }).$mount('#app')
    </script>
</body>
</html>